const rect = { x: 0, y: 10, width: 15, height: 20 };
// Destructuring assignment
const { x, y } = rect;
console.log(x, y); // 0 10

function f() {
    return [1, 2];
}
let a: number, b: number;
[a, b] = f();
console.log(a); // 1
console.log(b); // 2

function parseProtocol(url: string) {
    const parsedURL = /^(\w+)\:\/\/([^\/]+)\/(.*)$/.exec(url);
    if (!parsedURL) {
        return false;
    }
    console.log(parsedURL);
    // [
    //    "https://developer.mozilla.org/en-US/Web/JavaScript",
    //    "https", "developer.mozilla.org", "en-US/Web/JavaScript"
    // ]
    var [origin, protocol, _, fullpath] = parsedURL;
    return protocol;
}

const url = "https://developer.mozilla.org/en-US/Web/JavaScript"
const protocal = parseProtocol(url)
console.log(`protocal: ${protocal}`)

